package com.gpframework.module.common.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.common.domain.CommonWxMenu;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @ClassName CommonWxMenuReq
 * @Author gpframework
 * @Date 2023-08-15
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class CommonWxMenuReq extends BaseReq {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("主键")
    private Long wxMenuId;
    @ApiModelProperty("品牌id")
    private Long brandId;
    @ApiModelProperty("门店id")
    private Long storeId;
    @ApiModelProperty("父级id")
    private Long pid;
    @ApiModelProperty("会员类型：member、员工：employee")
    private String wxType;
    @ApiModelProperty("权限标识")
    private String component;
    @ApiModelProperty("目录名称")
    private String menuName;
    @ApiModelProperty("是否启用;0 否。1是。")
    private String enableFlag;
    @ApiModelProperty("排序")
    private Integer sort;

    /**
     * @Description 生成查询wrapper
     * @Author greatplan@qq.com
     * @Date 2020-11-04 16:04
     * @Param [lqw]
     * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
     * @Return void
     */
    public void generatorQuery(QueryWrapper<CommonWxMenu> lqw, boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias + "del_status", 0);
        }
        if (this.getWxMenuId() != null) {
            lqw.eq(alias + "wx_menu_id", this.getWxMenuId());
        }
        if (this.getBrandId() != null) {
            lqw.eq(alias + "brand_id", this.getBrandId());
        }
        if (this.getPid() != null) {
            lqw.eq(alias + "pid", this.getPid());
        }
        if (StringUtils.isNotBlank(this.getWxType())) {
            lqw.eq(alias + "wx_type", this.getWxType());
        }
        if (StringUtils.isNotBlank(this.getComponent())) {
            lqw.eq(alias + "component", this.getComponent());
        }
        if (StringUtils.isNotBlank(this.getMenuName())) {
            lqw.like(alias + "menu_name", this.getMenuName());
        }
        if (StringUtils.isNotBlank(this.getEnableFlag())) {
            lqw.eq(alias + "enable_flag", this.getEnableFlag());
        }
        if (this.getSort() != null) {
            lqw.eq(alias + "sort", this.getSort());
        }
    }
}
